import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:qyou_app/common/base.dart';

class GoodsItem extends StatelessWidget with Base{
  final String img;
  final String title;
  final String author;
  final String authorUrl;
  final String type;
  final double worksAspectRatio;
  GoodsItem(
      {this.img,
        this.title,
        this.author,
        this.authorUrl,
        this.type,
        this.worksAspectRatio});

  @override
  Widget build(BuildContext context) {
    return Card(
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.start,
        children: <Widget>[
          //商品图片
          Container(
            padding: EdgeInsets.all(dp(2)),
            child: CachedNetworkImage(
                imageUrl: '$img'
            ),
          ),
          //商品标题
          Container(
            padding:
            EdgeInsets.symmetric(horizontal: dp(5)),
            margin: EdgeInsets.symmetric(vertical: dp(5)),
            child: Text(
              '$title',
              style: TextStyle(fontSize: dp(12),),
              overflow: TextOverflow.ellipsis,
            ),
          ),
          //用户头像和作者
          Container(
            padding: EdgeInsets.only(
                left: dp(5),
                bottom: dp(5)),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.start,
              children: <Widget>[
                CircleAvatar(
                  backgroundImage: NetworkImage('$authorUrl'),
                  radius: dp(20),
                  // maxRadius: 40.0,
                ),
                Container(
                  margin: EdgeInsets.only(left: dp(20)),
                  width: dp(50),
                  child: Text(
                    '$author',
                    style: TextStyle(
                      fontSize: dp(12),
                    ),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(left: dp(25)),
                  child: Text(
                    '${type == 'EXISE' ? '汉服' : '古装'}',
                    style: TextStyle(
                      fontSize: dp(12),
                    ),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}
